const app = getApp();
import serviceData from '../../data/config';
import request from '../../utils/request'
Page({
    data : {
        products:[],
        currentPage:1,
        perPage : 5
    },
    onLoad(option){
        this.getProducts()
        // var categoryId = option.id;
        // var pageData = new Object();
        // pageData.page = this.data.currentPage;
        // pageData.per_page = this.data.perPage;
        // //request({path:'/categories/' + categoryId + '/products', data: pageData})
        //.then(({data:products}) => this.setData({products}));
        // this.setData({products: serviceData.categoryData});
        /*wx.setNavigationBarTitle({
          title: option.title,
          success: function(res) {
            // success
          }
        })*/
    },
    async getProducts(){
        let productData = await request('/cli/hot',{limit:10});
        this.setData({
            products: productData.data
        })
    },
    navigateToProduct(event) {
        var productId = event.currentTarget.dataset.goodsId;
        wx.navigateTo({
        url: '/pages/pro/pro?id=' + productId
        });
    },
});